<link rel="stylesheet" href="<?php echo URL::base() ?>media/vendor/css/style.css" type="text/css" media="all" />
<link rel="stylesheet" href="<?php echo URL::base() ?>media/vendor/artdialog/skins/default.css" type="text/css" media="all" />
<link href="<?php echo URL::base() ?>media/vendor/css/ui-lightness/jquery-ui-1.10.4.custom.css" rel="stylesheet">
<script src="<?php echo URL::base() ?>media/vendor/js/jquery-1.10.2.js"></script>
<script src="<?php echo URL::base() ?>media/vendor/js/jquery-ui-1.10.4.custom.js"></script>
<script src="<?php echo URL::base() ?>media/vendor/js/jquery.ui.datepicker-zh-TW.js"></script>
<script src="<?php echo URL::base() ?>media/vendor/js/Validform_v5.3.2_ncr_min.js"></script>
<script src="<?php echo URL::base() ?>media/vendor/artdialog/jquery.artDialog.js"></script>
<style>
.mypage{display: none;}
.table1 thead tr th,.table1 tbody tr td{ text-align:center;}
.form-horizontal .control-label{width: 80px;}
.form-horizontal .controls{margin-left: 90px;}
</style>
<script type="text/javascript">
url='';
function get_pandian(url){
	var dialog = art.dialog({title: '提示',icon:'question',lock: true});
	dialog.content('<p>数据查询中,请稍后...<p>');
	$.get(
    	    url,
    	    {
    	    	name: $("input[name='name']").val(),
    	    	sales_account: $("input[name='sales_account']").val(),
	    	    start_time: $("input[name='start_time']").val(),
	    	    end_time: $("input[name='end_time']").val(),
	    	 },
	    	  function(data){
	    	    	$('#table_content').empty();
	    	    	$('#table_content').html(data);
	    	    	$('#pager_links').empty();
	    	        $('.mypage').clone().appendTo('#pager_links').show();
 	    		dialog.close();
	   	   }
    	 );
}
$(function() {
	$.datepicker.setDefaults({ dateFormat: 'yy-mm-dd' });
	$("#start").datepicker({  
	    onSelect:function(dateText,inst){  
	       $("#end").datepicker("option","minDate",dateText);  
	    }  
	});  
	$("#end").datepicker({  
	    onSelect:function(dateText,inst){  
	        $("#start").datepicker("option","maxDate",dateText);  
	    }  
	}); 
	$("#search").click(function(){
	    url='<?php echo URL::base() ?>inventory/rate/searchto';
		get_pandian(url);
	});
  $(document).on('click', '.pagination a', function(e){
  	  e.preventDefault(); 
        url =$(this).attr('href');
        if(url.length){
        	get_pandian(url);
        }
        
     });
  
   $(document).on('focus', ".rate", function(){
	     var tds=$(this).parent().siblings();
		  var btn=tds.eq(4).find('input');
		  btn.attr('class','btn btn-info btn-danger btn-save').attr('disabled',false).val('保存');
		});
   $(document).on('click', ".btn-save", function(){
	      $(this).attr('class','btn btn-info').attr('disabled',true).val('已保存');
		  var tds=$(this).parent().siblings();
		  var id=tds.eq(0).text();
		  var rate1=tds.eq(2).find('input').val();
		  var rate2=tds.eq(3).find('input').val();
		  $.get(
				    '<?php echo URL::base() ?>inventory/rate/edit',
		    	     {
		    	    	id: id,
		    	    	rate1:rate1,
		    	    	rate2:rate2,
			    	 },
			    	  function(data){
			   	   }
		    	 );
		});
});
</script>
<div class="row">
		<div class="span11">
			<form class="form-horizontal upSuppForm" >
					<div class="control-group">
    	      		<label class="control-label w-label">币种:</label>
					<div class="controls">
					<input type="text"  value=""  style=" width:164px;" name="name"  class="inputxt"  />
					  
					</div>
					
				</div>
					<div class="control-group">
    	      		<label class="control-label w-label">起止时间:</label>
					<div class="controls">
						 <input type="text" style=" width:164px;" name='start_time' class=" datepicker" id="start" value="<?php echo date('Y-m-d'); ?>" readonly="readonly"> ~
						<input type="text" name='end_time'  style=" width:164px;" class="datepicker" id="end" value="<?php echo date('Y-m-d'); ?>" readonly="readonly">
						<div class="btn btn-info" style=" margin-left:10px;" id="search">查询</div>
					</div>
					
				</div>
			</form>
			<table class="table table1 table-bordered">
              <thead>
                <tr style="background-color:#4EA392; font-weight:bold; color:#ffffff;">
                  <th>币种</th>
                  <th>人民币汇率</th>
                  <th>美元汇率</th>
                  <th>添加时间</th>
                  <th>操作</th>
                </tr>
              </thead>
              <tbody id='table_content'>
              </tbody>
            </table>
              <div id="pager_links"></div>
		</div>
		<div class="span2"></div>
	</div>
